<template>
  <CommonCard title="今日销售额" :value="numberFormater(salesToday)">
    <template #default>
      <div class="compare">
        <div class="emphasis">日同比 &nbsp;{{numberFormater(salesGrowthLastDay)  }}%&nbsp;<span class="decrement"></span></div>
        <div class="emphasis">月同比 &nbsp;{{numberFormater(salesGrowthLastMonth)  }}%&nbsp;<span class="increment"></span></div>
      </div>
    </template>
    <template #footer>
      <div>昨日销售额 <span class="emphasis">{{moneyFormater(salesLastDay)  }}</span></div>
    </template>
  </CommonCard>
</template>

<script lang="ts" >
import { defineComponent } from "vue";
export default defineComponent({
  name: "TodaySales",
});
</script>
<script lang="ts" setup>
import { computed } from "vue";
import CommonCard from "./CommonCard.vue";
import {useReportDataStore} from '@/stores/reportData'
import useFormater from '@/hooks/useFormater'
const reportDataStore = useReportDataStore()
const {numberFormater,moneyFormater} = useFormater()

//今日销售额
const salesToday = computed(()=>reportDataStore.reportData.salesToday)
//昨日销售额
const salesLastDay = computed(()=>reportDataStore.reportData.salesLastDay)
// 3. 日同比
const salesGrowthLastDay = computed(() => reportDataStore.reportData.salesGrowthLastDay)
// 4. 月同比
const salesGrowthLastMonth = computed(() => reportDataStore.reportData.salesGrowthLastMonth)

</script>

<style scoped lang="scss">
.compare {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  > div {
    display: flex;
    align-items: center;
  }
}
</style>